home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19981211-19990422 / 000265_news@watsun.cc.columbia.edu _Mon Feb 22 18:58:46 1999.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Return-Path: <news@watsun.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id SAA28375
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Mon, 22 Feb 1999 18:58:45 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id SAA23264
  7.     for kermit.misc@watsun.cc.columbia.edu; Mon, 22 Feb 1999 18:38:26 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Subject: Re: Don't want to send file if filesize grows
  11. Date: 22 Feb 1999 23:38:19 GMT
  12. Organization: Columbia University
  13. Message-ID: <7asppb$mmr$1@newsmaster.cc.columbia.edu>
  14. To: kermit.misc@mailrelay2.cc.columbia.edu
  15.  
  16. In article <19990222180043.02874.00001668@ng-fx1.aol.com>,
  17. OhOhTrubba <ohohtrubba@aol.com> wrote:
  18. : I have a directory called testdirectory.  It has files constantly coming
  19. : into it 24 hours a day.  I need to have a script send these files to
  20. : another directory on another filesystem; however, I have to make sure the
  21. : file is complete first otherwise I'll send over partial data.  I'm
  22. : visualizing in my head something involving ls'ing the directory and
  23. : looking at the filesize bytes.  Then five minutes later, looking at the
  24. : filesize again and if the filesize does NOT grow, send the file.  If it
  25. : does grow, leave the file where it's at and check it again in another five
  26. : minutes.  However, I'm new to Unix and don't even know where to begin.  I
  27. : know ls could look at the files, awk could grab the filesize bytes and
  28. : cron could make something happen every five minutes, but other than that,
  29. : I'm clueless.  HELP, please.
  30. :
  31. You didn't say how you are transferring the files, but tasks like these are
  32. easily accomplished (and automated) using C-Kermit scripts.  The easiest
  33. approach is to send a file to Directory A, and then move it to Directory B
  34. after it is completely transferred.  Or rename it to a name that indicates
  35. it has been fully transferred.  For example, let's say a Kermit server is
  36. running on your AIX host, and its current directory is "tmp", which is 
  37. parallel with "testdir".  The client does:
  38.  
  39.   send blah  ; ("blah" is the filename) 
  40.   if success remote rename blah ../testdir/blah
  41.  
  42. This ensures that the file is moved to testdir if and only if it was
  43. transferred fully and successfully.
  44.  
  45. Meanwhile your other process on the same AIX system is looking for files to
  46. appear in testdir.  Let's say "testdir" is its current directory.  It can do
  47. something like this:
  48.  
  49.   while true {
  50.       assign \%n \ffiles(*,&f)   ; Look for any files (1)
  51.       xif > \%n 0 {              ; There are some
  52.           for \%i 1 \%n 1 {      ; Loop through the list
  53.               move \&f[\%i]      ; Send each file (2)
  54.           }
  55.       } else {                   ; No files to send
  56.           sleep 10               ; Sleep 10 seconds
  57.       }
  58.   }
  59.  
  60. Notes:
  61.  
  62.  (1) \ffiles(*,&f) assigns the list of all files whose names match the
  63.      pattern ("*" in this case) to the array \&f[].  C-Kermit 7.0 (currently
  64.      in Beta test) is required to use this feature; somewhat less convenient
  65.      methods are available in earlier versions.
  66.  
  67.  (2) The "move" command means "send the file and then, if and only if the
  68.      transfer was successful, delete it".  This ensures the same file won't
  69.      be sent twice.  Note that we don't care about failure here; if a file
  70.      is not transferred successfully, we'll catch it again next time through
  71.      the loop.
  72.  
  73. More info about C-Kermit at:
  74.  
  75.   http://www.columbia.edu/kermit/ckermit.html
  76.  
  77. And about C-Kermit 7.0 at:
  78.  
  79.   http://www.columbia.edu/kermit/ck70.html
  80.  
  81. - Frank